'''
Created on 26/03/2011

@author: andrew
'''

from MP3file import MP3file
from OGGfile import OGGfile
from Database import Session
from DatabaseClasses import Music

mp3filetest = MP3file("/home/andrew/tmp/teste3.mp3")

music = Music(musicFile=mp3filetest)

print music.path
print music.musicFile.length

print '----------------------------------------------------'

s = Session()

result = s.query(Music).filter(Music.path == music.path)

if result.count() == 0:
    print "Musica nao encontrada. Adicionando..."
    s.add(music)
    s.commit()

print '----------------------------------------------------'

for i in s.query(Music):
    print i.artist
    print i.id
    print i.album
    print i.title
    print i.path
    print i.musicFile.length
    print i

print '----------------------------------------------------'

s.close()
